export default {
	rules:{
		tel:/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/,
		phone:/^(13[0-9]|14[57]|15[012356789]|17[67]|18[012356789])\d{8}$/,
		email:/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
		password:/^[a-zA-Z0-9]{6,20}$/
	},
	formatDataTimeByDay(value, row, index){
	    if(value == null || value == "null") return "";
	    if( (typeof value=='string')&&value.constructor==String)
	      value=(value+"").replace("T"," ");
	    var newdate = new Date(value);
	    var str = "";
	    //str += newdate.getFullYear() + "-";
	    if (newdate.getMonth() < 9) {
	      str += ("0" + (newdate.getMonth() + 1) + ".");
	    } else {
	      str += (newdate.getMonth() + 1) + ".";
	    }
	    if (newdate.getDate() < 10) {
	      str += ("0" + newdate.getDate() + "");
	    } else {
	      str += newdate.getDate() + "";
	    }
	    /*str += newdate.getHours() + ":";
	    if (newdate.getMinutes() < 10) {
	      str += ("0" + newdate.getMinutes());
	    } else {
	      str += newdate.getMinutes();
	    }*/
	
	    return str;
	  },
	/* start 右上角成功提示 */
	openSuccess(_this,msg) {
		_this.$notify({
			message: msg,
			type: 'success',
			duration: 3000
		});
	},
	/* end 右上角成功提示 */
	/* start 右上角失败提示 */
	openError(_this,msg) {
		_this.$notify({
			message: msg,
			type: 'error',
			duration: 3000
		});
	},
	/* end 右上角失败提示 */
	/* start 右上角失败提示 */
	openInfo(_this,msg) {
		_this.$notify({
			message: msg,
			type: 'info',
			duration: 3000
		});
	},
	/* end 右上角失败提示 */
	/* start cookie */
	setCookie(c_name, value, expiredays){
		var exdate=new Date();
		exdate.setDate(exdate.getDate() + expiredays);
		document.cookie=c_name+ "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	},
	getCookie(name){
		var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
		if(arr=document.cookie.match(reg)){
			return unescape(arr[2]);
		}else{
			return null;
		}
	},
	delCookie(name){
		var exp = new Date();
		exp.setTime(exp.getTime() - 1);
		var cval= this.getCookie(name);
		if(cval!=null)
		document.cookie= name + "="+cval+";expires="+exp.toGMTString();
	},
	/* end cookie */
	/* start 数组去重 */
	array_remove_repeat(a) {
	    var r = [];
	    for(var i = 0; i < a.length; i ++) {
	        var flag = true;
	        var temp = a[i];
	        for(var j = 0; j < r.length; j ++) {
	            if(temp === r[j]) {
	                flag = false;
	                break;
	            }
	        }
	        if(flag) {
	            r.push(temp);
	        }
	    }
	    return r;
	},
	/* end 数组去重 */
	/* start 数组组合 */
    arraysplitAll(a){
        var result =[];
        
        if(a.length==0){
            return result;
        }else if(a.length==1){
            return a[0];
        }else if(a.length==2){
            return arraysplit(a[0],a[1]);
        }else{
            result = arraysplit(a[0],a[1]);
            a.splice(0,2);
            for(var i=0;i< a.length;i++){
                var temp = arraysplit(result,a[i]);
                result = temp;
            }
            return result;
        };
        
        function arraysplit(array1,array2){
            var result = [];
            if(array1.length==0&&array2.length==0){
            	result.push(",")
                return result;
            }else if(array1.length==0&&array2.length!=0){
                for(var j=0;j<array2.length;j++){
                    result.push(','+array2[j]);
                }
                return result;
            }else if(array1.length!=0&&array2.length==0){
                for(var i=0;i<array1.length;i++){
                    result.push(array1[i]+',');
                }
                return result;
            }else{
                for(var i=0;i<array1.length;i++){
                    for(var j=0;j<array2.length;j++){
                        result.push(array1[i]+','+array2[j]);
                    }
                }
           		return result;
            }
        }
    },
	/* end 数组组合 */
	/* start 金额数据处理 */
	formatMoney  (num, n) {
	    if(undefined ==  num || "" == num || null == num || "0" == num){
	      return "0.00";
	    }else{
	      num = String(num.toFixed(n ? n : 2));
	      var re = /(-?\d+)(\d{3})/;
	      while (re.test(num)) num = num.replace(re, "$1,$2");
	      return n ? num : num.replace(/^([0-9,]+\.[1-9])0$/, "$1").replace(/^([0-9,]+)\.00$/, "$1");
	    }
	},
	/* end 金额数据处理 */
	
}
